<html><head><meta charset="gb2312"/><title>ToolBar.pb</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<pre><font face="Courier New, Courier, mono"size="2"><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font><font color="#3A3966">;   PureBasic - ToolBar example file
</font><font color="#3A3966">;
</font><font color="#3A3966">;    (c) Fantaisie Software
</font><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font>

<b><font color="#3A3966">If</font></b> <font color="#3A3966">OpenWindow</font>(0, 100, 200, 195, 260, "ToolBar example", <font color="#FF0000">#PB_Window_SystemMenu</font> | <font color="#FF0000">#PB_Window_SizeGadget</font>)

  <b><font color="#3A3966">If</font></b> <font color="#3A3966">CreateToolBar</font>(0,<font color="#3A3966"> WindowID</font>(0))
<font color="#3A3966">    ToolBarStandardButton</font>(0, <font color="#FF0000">#PB_ToolBarIcon_New</font>)
<font color="#3A3966">    ToolBarStandardButton</font>(1, <font color="#FF0000">#PB_ToolBarIcon_Open</font>)
<font color="#3A3966">    ToolBarStandardButton</font>(2, <font color="#FF0000">#PB_ToolBarIcon_Save</font>)
    
<font color="#3A3966">    ToolBarSeparator</font>()

<font color="#3A3966">    ToolBarStandardButton</font>(3, <font color="#FF0000">#PB_ToolBarIcon_Print</font>)
<font color="#3A3966">    ToolBarToolTip</font>(0, 3, "Print")
    
<font color="#3A3966">    ToolBarStandardButton</font>(4, <font color="#FF0000">#PB_ToolBarIcon_Find</font>)
<font color="#3A3966">    ToolBarToolTip</font>(0, 4, "Find a document")
    
<font color="#3A3966">    ToolBarSeparator</font>()
    
    <b><font color="#3A3966">CompilerIf</font></b> <font color="#FF0000">#PB_Compiler_OS</font> = <font color="#FF0000">#PB_OS_Windows</font>  
      <font color="#3A3966">; The .ico format is available only on Windows
</font><font color="#3A3966">      ToolBarImageButton</font>(5,<font color="#3A3966"> LoadImage</font>(0, "Data/CdPlayer.ico"))
    <b><font color="#3A3966">CompilerEndIf</font></b>
  <b><font color="#3A3966">EndIf</font></b>


  <b><font color="#3A3966">If</font></b> <font color="#3A3966">CreateMenu</font>(0,<font color="#3A3966"> WindowID</font>(0))
<font color="#3A3966">    MenuTitle</font>("Project")
<font color="#3A3966">      MenuItem</font>(0, "New")
<font color="#3A3966">      MenuItem</font>(1, "Open")
<font color="#3A3966">      MenuItem</font>(2, "Save")
  <b><font color="#3A3966">EndIf</font></b>
  
  <font color="#3A3966">;
</font>  <font color="#3A3966">; Attach our previously created ToolBar to this window
</font>  <font color="#3A3966">;
</font>    
<font color="#3A3966">  DisableToolBarButton</font>(0, 2, 1) <font color="#3A3966">; Disable the button '2'
</font>  
  <font color="#3A3966">;
</font>  <font color="#3A3966">; The event loop. A ToolBar event is like a Menu event (as tools are shortcut for menu the most
</font>  <font color="#3A3966">; of the time). This is handy, as if the ToolBar buttons and the MenuItem have the same ID, then
</font>  <font color="#3A3966">; the same operation can be done on both action without any adds..
</font>  <font color="#3A3966">;
</font>  
  <b><font color="#3A3966">Repeat</font></b>
    Event =<font color="#3A3966"> WaitWindowEvent</font>()

    <b><font color="#3A3966">Select</font></b> Event
    
      <b><font color="#3A3966">Case</font></b> <font color="#FF0000">#PB_Event_Menu</font>
<font color="#3A3966">        MessageRequester</font>("Information", "ToolBar or Menu ID: "+<font color="#3A3966">Str</font>(<font color="#3A3966">EventMenu</font>()), 0)
      
      <b><font color="#3A3966">Case</font></b> <font color="#FF0000">#PB_Event_CloseWindow</font>  <font color="#3A3966">; If the user has pressed on the close button
</font>        Quit = 1
        
    <b><font color="#3A3966">EndSelect</font></b>

  <b><font color="#3A3966">Until</font></b> Quit = 1
  
<b><font color="#3A3966">EndIf</font></b>

<b><font color="#3A3966">End</font></b>   <font color="#3A3966">; All the opened windows are closed automatically by PureBasic
</font>   -</font></pre>
</body></html>
